home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / PROGTOOL / FLI106C.ZIP;1 / WINMOVE.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1992-03-12  |  3.9 KB  |  164 lines

  1. //
  2. // The Fusion Library Interface for DOS
  3. // Version 1.06c
  4. // Copyright (C) 1990, 1991, 1992
  5. // Software Dimensions
  6. //
  7. // FusionWindow
  8. //
  9.  
  10. #include "fliwin.h"
  11. #include "colors.h"
  12.  
  13. #ifdef __BCPLUSPLUS__
  14. #pragma hdrstop
  15. #endif
  16.  
  17. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  18. //
  19. // MoveWindow()
  20. //
  21. // Moves the window using the keyboard
  22. //
  23. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  24.  
  25. void FusionWindow::MoveWindow()
  26. {
  27.   if (!NumberOfWindows)
  28.     return;
  29.  
  30.   BlazeClass::InvisibleCursor();
  31.  
  32.   RemoveAllMenus();
  33.  
  34.   WindowElement &Window=*Windows[0];
  35.  
  36.   char *EntireWindow=
  37.     new char[Blaze.ComputeNeededBytes(Blaze.WhatWidth(),Blaze.WhatHeight())];
  38.   char *ThisWindow=
  39.     new char[Blaze.ComputeNeededBytes(Window.Width,Window.Height)];
  40.   char *SpareWindow=
  41.     new char[Blaze.ComputeNeededBytes(Window.Width,Window.Height)];
  42.  
  43.   Blaze.UseMemory(EntireWindow);
  44.   Blaze.CharacterFill(0,1,Blaze.WhatWidth(),Blaze.WhatHeight()-2,
  45.     Colors.WorkSpace,176);
  46.  
  47.   if (NumberOfWindows>1)
  48.   {
  49.     for (register int i=NumberOfWindows-1;i;i--)
  50.     {
  51.       Windows[i]->Blaze.UseMemory(EntireWindow);
  52.       Windows[i]->ShowWindow();
  53.       Windows[i]->ShowInterior();
  54.       Windows[i]->Blaze.UseVideo();
  55.     }
  56.   }
  57.  
  58.   Blaze.HelpLine(0,"Use the keyboard to move the window");
  59.  
  60.   Blaze.GetArea(Window.X,Window.Y,Window.Width,Window.Height,ThisWindow);
  61.  
  62.   Window.Blaze.UseMemory(EntireWindow);
  63.   Window.ShowWindow();
  64.   Window.ShowInterior();
  65.   Window.Blaze.UseVideo();
  66.  
  67.   MouseHide();
  68.  
  69.   Blaze.BlockCopyVirtualToVisual(0,1,Blaze.WhatWidth(),Blaze.WhatHeight()-2,
  70.     EntireWindow);
  71.   Blaze.GetArea(Window.X,Window.Y,Window.Width,Window.Height,SpareWindow);
  72.  
  73.   MouseShow();
  74.  
  75.   for (;;)
  76.   {
  77.     int Event=GetEvent();
  78.  
  79.     if (Event==MousedEvent && MouseEvent&MouseLeftButtonPress)
  80.     {
  81.       if ((Window.SizeIcon &&
  82.            MouseVertical==Window.Y+Window.Height-1 &&
  83.            MouseHorizontal==Window.X+Window.Width-1) ||
  84.           (Window.Moveable &&
  85.            MouseVertical==Window.Y &&
  86.            MouseHorizontal>=(Window.X+(Window.CloseIcon*3)+1) &&
  87.            MouseHorizontal<=(Window.X+Window.Width-(Window.ZoomIcon*3)-3)))
  88.       {
  89.         LastShift=500;
  90.         KeyLast=500;
  91.         delete SpareWindow;
  92.         delete ThisWindow;
  93.         delete EntireWindow;
  94.         Blaze.UseVideo();
  95.         Window.ShowWindow();
  96.         Window.ShowInterior();
  97.         CheckMoveOrSize();
  98.         return;
  99.       }
  100.     }
  101.  
  102.     if (Event==kbCr || Event==kbEsc)
  103.     {
  104.       LastShift=500;
  105.       KeyLast=500;
  106.       delete SpareWindow;
  107.       delete ThisWindow;
  108.       delete EntireWindow;
  109.       Blaze.UseVideo();
  110.       Window.ReAlign();
  111.       Window.Cursor();
  112.       Window.EventHandler(MoveEvent);
  113.       return;
  114.     }
  115.  
  116.     if (Event==kbRight || Event==kbLeft || Event==kbUp || Event==kbDown)
  117.     {
  118.       MouseHide();
  119.  
  120.       Blaze.PutArea(Window.X,Window.Y,ThisWindow);
  121.       delete ThisWindow;
  122.  
  123.       int ActionX=0, ActionY=0;
  124.  
  125.       if (Event==kbRight)
  126.         ActionX=1;
  127.       else if (Event==kbLeft)
  128.         ActionX=-1;
  129.       else if (Event==kbUp)
  130.         ActionY=-1;
  131.       else
  132.         ActionY=1;
  133.  
  134.       Window.X+=ActionX;
  135.       Window.Y+=ActionY;
  136.  
  137.       if (Window.X<0)
  138.         Window.X=0;
  139.  
  140.       if (Window.Y<1)
  141.         Window.Y=1;
  142.  
  143.       if (Window.X+Window.Width>Blaze.WhatWidth())
  144.         Window.X=Blaze.WhatWidth()-Window.Width;
  145.  
  146.       if (Window.Y+Window.Height>Blaze.WhatHeight()-1)
  147.         Window.Y=Blaze.WhatHeight()-Window.Height-1;
  148.  
  149.       ThisWindow=
  150.         new char[Blaze.ComputeNeededBytes(Window.Width,Window.Height)];
  151.       Blaze.GetArea(Window.X,Window.Y,Window.Width,Window.Height,ThisWindow);
  152.       Blaze.PutArea(Window.X,Window.Y,SpareWindow);
  153.  
  154.       MouseHide();
  155.  
  156.       Blaze.BlockCopyVirtualToVisual(0,1,Blaze.WhatWidth(),Blaze.WhatHeight()-2,
  157.         EntireWindow);
  158.  
  159.       MouseShow();
  160.     }
  161.   }
  162. }
  163.  
  164.